/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('contactcenterai', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AnalyzeAudioSyncRequest {
  categoryTags?: [ 
    {
      tagDesc?: string(name='tagDesc'),
      tagName?: string(name='tagName'),
    }
  ](name='categoryTags'),
  customPrompt?: string(name='customPrompt'),
  fields?: [ 
    {
      code?: string(name='code', example='phoneNumber'),
      desc?: string(name='desc'),
      enumValues?: [ 
        {
          desc?: string(name='desc'),
          enumValue?: string(name='enumValue'),
        }
      ](name='enumValues'),
      name?: string(name='name'),
    }
  ](name='fields'),
  modelCode?: string(name='modelCode', example='tyxmTurbo'),
  responseFormatType?: string(name='responseFormatType', example='jsonObject'),
  resultTypes?: [ string ](name='resultTypes'),
  serviceInspection?: {
    inspectionContents?: [ 
      {
        content?: string(name='content'),
        title?: string(name='title'),
      }
    ](name='inspectionContents'),
    inspectionIntroduction?: string(name='inspectionIntroduction'),
    sceneIntroduction?: string(name='sceneIntroduction'),
  }(name='serviceInspection'),
  stream?: boolean(name='stream', description='This parameter is required.', example='false'),
  templateIds?: [ string ](name='templateIds'),
  transcription?: {
    asrModelCode?: string(name='asrModelCode', example='nls'),
    autoSplit?: int32(name='autoSplit', example='1'),
    clientChannel?: int32(name='clientChannel', example='1'),
    fileName?: string(name='fileName', description='This parameter is required.', example='sss.mp3'),
    level?: string(name='level', example='low'),
    serviceChannel?: int32(name='serviceChannel', example='1'),
    serviceChannelKeywords?: [ string ](name='serviceChannelKeywords'),
    vocabularyId?: string(name='vocabularyId', example='esnvknv*****skdnvjksd'),
    voiceFileUrl?: string(name='voiceFileUrl', description='This parameter is required.', example='http://1111.com/sss.mp3'),
  }(name='transcription'),
  variables?: [ 
    {
      variableCode?: string(name='variableCode', example='name'),
      variableValue?: string(name='variableValue'),
    }
  ](name='variables'),
}

model AnalyzeAudioSyncResponseBody = {
  finishReason?: string(name='finishReason', example='stop'),
  inputTokens?: string(name='inputTokens', example='1000'),
  outputTokens?: string(name='outputTokens', example='2000'),
  requestId?: string(name='requestId', example='968A8634-FA2C-5381-9B3E-*******F'),
  success?: boolean(name='success', example='True'),
  text?: string(name='text'),
  totalTokens?: string(name='totalTokens', example='3000'),
}

model AnalyzeAudioSyncResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AnalyzeAudioSyncResponseBody(name='body'),
}

/**
 * @summary 语音文件分析任务极速版
 *
 * @param request AnalyzeAudioSyncRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return AnalyzeAudioSyncResponse
 */
async function analyzeAudioSyncWithOptions(workspaceId: string, appId: string, request: AnalyzeAudioSyncRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AnalyzeAudioSyncResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.categoryTags)) {
    body['categoryTags'] = request.categoryTags;
  }
  if (!Util.isUnset(request.customPrompt)) {
    body['customPrompt'] = request.customPrompt;
  }
  if (!Util.isUnset(request.fields)) {
    body['fields'] = request.fields;
  }
  if (!Util.isUnset(request.modelCode)) {
    body['modelCode'] = request.modelCode;
  }
  if (!Util.isUnset(request.responseFormatType)) {
    body['responseFormatType'] = request.responseFormatType;
  }
  if (!Util.isUnset(request.resultTypes)) {
    body['resultTypes'] = request.resultTypes;
  }
  if (!Util.isUnset(request.serviceInspection)) {
    body['serviceInspection'] = request.serviceInspection;
  }
  if (!Util.isUnset(request.stream)) {
    body['stream'] = request.stream;
  }
  if (!Util.isUnset(request.templateIds)) {
    body['templateIds'] = request.templateIds;
  }
  if (!Util.isUnset(request.transcription)) {
    body['transcription'] = request.transcription;
  }
  if (!Util.isUnset(request.variables)) {
    body['variables'] = request.variables;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AnalyzeAudioSync',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/${OpenApiUtil.getEncodeParam(workspaceId)}/ccai/app/${OpenApiUtil.getEncodeParam(appId)}/analyzeAudioSync`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 语音文件分析任务极速版
 *
 * @param request AnalyzeAudioSyncRequest
 * @return AnalyzeAudioSyncResponse
 */
async function analyzeAudioSync(workspaceId: string, appId: string, request: AnalyzeAudioSyncRequest): AnalyzeAudioSyncResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return analyzeAudioSyncWithOptions(workspaceId, appId, request, headers, runtime);
}

model AnalyzeConversationRequest {
  categoryTags?: [ 
    {
      tagDesc?: string(name='tagDesc'),
      tagName?: string(name='tagName'),
    }
  ](name='categoryTags'),
  customPrompt?: string(name='customPrompt'),
  dialogue?: {
    sentences?: [ 
      {
        role?: string(name='role', description='This parameter is required.', example='user'),
        text?: string(name='text', description='This parameter is required.'),
      }
    ](name='sentences', description='This parameter is required.'),
    sessionId?: string(name='sessionId', example='session-01'),
  }(name='dialogue'),
  examples?: [ 
    {
      output?: string(name='output', description='This parameter is required.'),
      sentences?: [ 
        {
          chatId?: string(name='chatId'),
          role?: string(name='role', description='This parameter is required.'),
          text?: string(name='text', description='This parameter is required.'),
        }
      ](name='sentences', description='This parameter is required.'),
    }
  ](name='examples'),
  fields?: [ 
    {
      code?: string(name='code', example='phoneNumber'),
      desc?: string(name='desc', description='This parameter is required.'),
      enumValues?: [ 
        {
          desc?: string(name='desc', description='This parameter is required.'),
          enumValue?: string(name='enumValue', description='This parameter is required.'),
        }
      ](name='enumValues'),
      name?: string(name='name', description='This parameter is required.'),
    }
  ](name='fields'),
  modelCode?: string(name='modelCode', example='tyxmTurbo'),
  responseFormatType?: string(name='responseFormatType'),
  resultTypes?: [ string ](name='resultTypes', description='This parameter is required.'),
  sceneName?: string(name='sceneName'),
  serviceInspection?: {
    inspectionContents?: [ 
      {
        content?: string(name='content', description='This parameter is required.'),
        title?: string(name='title', description='This parameter is required.'),
      }
    ](name='inspectionContents', description='This parameter is required.'),
    inspectionIntroduction?: string(name='inspectionIntroduction', description='This parameter is required.'),
    sceneIntroduction?: string(name='sceneIntroduction', description='This parameter is required.'),
  }(name='serviceInspection'),
  sourceCallerUid?: string(name='sourceCallerUid'),
  stream?: boolean(name='stream', description='This parameter is required.', example='false'),
  timeConstraintList?: [ string ](name='timeConstraintList'),
  userProfiles?: [ 
    {
      name?: string(name='name'),
      value?: string(name='value'),
    }
  ](name='userProfiles'),
}

model AnalyzeConversationResponseBody = {
  errorCode?: string(name='errorCode', example='InvalidUser.NotFound'),
  errorInfo?: string(name='errorInfo'),
  finishReason?: string(name='finishReason', example='stop'),
  inputTokens?: string(name='inputTokens'),
  outputTokens?: string(name='outputTokens'),
  requestId?: string(name='requestId', example='968A8634-FA2C-5381-9B3E-C552DED7E8BF'),
  success?: boolean(name='success', example='True'),
  text?: string(name='text'),
  totalTokens?: string(name='totalTokens'),
}

model AnalyzeConversationResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AnalyzeConversationResponseBody(name='body'),
}

/**
 * @summary 根据类型调用大模型
 *
 * @param request AnalyzeConversationRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return AnalyzeConversationResponse
 */
async function analyzeConversationWithOptions(workspaceId: string, appId: string, request: AnalyzeConversationRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AnalyzeConversationResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.categoryTags)) {
    body['categoryTags'] = request.categoryTags;
  }
  if (!Util.isUnset(request.customPrompt)) {
    body['customPrompt'] = request.customPrompt;
  }
  if (!Util.isUnset(request.dialogue)) {
    body['dialogue'] = request.dialogue;
  }
  if (!Util.isUnset(request.examples)) {
    body['examples'] = request.examples;
  }
  if (!Util.isUnset(request.fields)) {
    body['fields'] = request.fields;
  }
  if (!Util.isUnset(request.modelCode)) {
    body['modelCode'] = request.modelCode;
  }
  if (!Util.isUnset(request.responseFormatType)) {
    body['responseFormatType'] = request.responseFormatType;
  }
  if (!Util.isUnset(request.resultTypes)) {
    body['resultTypes'] = request.resultTypes;
  }
  if (!Util.isUnset(request.sceneName)) {
    body['sceneName'] = request.sceneName;
  }
  if (!Util.isUnset(request.serviceInspection)) {
    body['serviceInspection'] = request.serviceInspection;
  }
  if (!Util.isUnset(request.sourceCallerUid)) {
    body['sourceCallerUid'] = request.sourceCallerUid;
  }
  if (!Util.isUnset(request.stream)) {
    body['stream'] = request.stream;
  }
  if (!Util.isUnset(request.timeConstraintList)) {
    body['timeConstraintList'] = request.timeConstraintList;
  }
  if (!Util.isUnset(request.userProfiles)) {
    body['userProfiles'] = request.userProfiles;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AnalyzeConversation',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/${OpenApiUtil.getEncodeParam(workspaceId)}/ccai/app/${OpenApiUtil.getEncodeParam(appId)}/analyze_conversation`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 根据类型调用大模型
 *
 * @param request AnalyzeConversationRequest
 * @return AnalyzeConversationResponse
 */
async function analyzeConversation(workspaceId: string, appId: string, request: AnalyzeConversationRequest): AnalyzeConversationResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return analyzeConversationWithOptions(workspaceId, appId, request, headers, runtime);
}

model AnalyzeImageRequest {
  imageUrls?: [ string ](name='imageUrls'),
  responseFormatType?: string(name='responseFormatType'),
  resultTypes?: [ string ](name='resultTypes'),
  stream?: boolean(name='stream', description='This parameter is required.', example='false'),
}

model AnalyzeImageResponseBody = {
  finishReason?: string(name='finishReason', example='stop'),
  inputTokens?: string(name='inputTokens', example='1000'),
  outputTokens?: string(name='outputTokens', example='2000'),
  requestId?: string(name='requestId', example='9*****-AE0D-5EE3-B1AF-48632CB0831C'),
  success?: boolean(name='success', example='True'),
  text?: string(name='text'),
  totalTokens?: string(name='totalTokens', example='3000'),
}

model AnalyzeImageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AnalyzeImageResponseBody(name='body'),
}

/**
 * @summary 图片分析
 *
 * @param request AnalyzeImageRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return AnalyzeImageResponse
 */
async function analyzeImageWithOptions(workspaceId: string, appId: string, request: AnalyzeImageRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AnalyzeImageResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.imageUrls)) {
    body['imageUrls'] = request.imageUrls;
  }
  if (!Util.isUnset(request.responseFormatType)) {
    body['responseFormatType'] = request.responseFormatType;
  }
  if (!Util.isUnset(request.resultTypes)) {
    body['resultTypes'] = request.resultTypes;
  }
  if (!Util.isUnset(request.stream)) {
    body['stream'] = request.stream;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'AnalyzeImage',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/${OpenApiUtil.getEncodeParam(workspaceId)}/ccai/app/${OpenApiUtil.getEncodeParam(appId)}/analyzeImage`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 图片分析
 *
 * @param request AnalyzeImageRequest
 * @return AnalyzeImageResponse
 */
async function analyzeImage(workspaceId: string, appId: string, request: AnalyzeImageRequest): AnalyzeImageResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return analyzeImageWithOptions(workspaceId, appId, request, headers, runtime);
}

model CreateTaskRequest {
  categoryTags?: [ 
    {
      tagDesc?: string(name='tagDesc'),
      tagName?: string(name='tagName'),
    }
  ](name='categoryTags'),
  customPrompt?: string(name='customPrompt'),
  dialogue?: {
    sentences?: [ 
      {
        role?: string(name='role', description='This parameter is required.', example='user'),
        text?: string(name='text', description='This parameter is required.'),
      }
    ](name='sentences', description='This parameter is required.'),
    sessionId?: string(name='sessionId', example='session-01'),
  }(name='dialogue'),
  examples?: {
    output?: string(name='output'),
    sentences?: [ 
      {
        role?: string(name='role', description='This parameter is required.', example='user'),
        text?: string(name='text', description='This parameter is required.'),
      }
    ](name='sentences', description='This parameter is required.'),
  }(name='examples'),
  fields?: [ 
    {
      code?: string(name='code', example='phoneNumber'),
      desc?: string(name='desc', description='This parameter is required.'),
      enumValues?: [ 
        {
          desc?: string(name='desc', description='This parameter is required.'),
          enumValue?: string(name='enumValue', description='This parameter is required.'),
        }
      ](name='enumValues'),
      name?: string(name='name', description='This parameter is required.'),
    }
  ](name='fields'),
  modelCode?: string(name='modelCode', description='This parameter is required.', example='tyxmTurbo'),
  responseFormatType?: string(name='responseFormatType'),
  resultTypes?: [ string ](name='resultTypes'),
  serviceInspection?: {
    inspectionContents?: [ 
      {
        content?: string(name='content', description='This parameter is required.'),
        title?: string(name='title', description='This parameter is required.'),
      }
    ](name='inspectionContents', description='This parameter is required.'),
    inspectionIntroduction?: string(name='inspectionIntroduction', description='This parameter is required.'),
    sceneIntroduction?: string(name='sceneIntroduction', description='This parameter is required.'),
  }(name='serviceInspection'),
  taskType?: string(name='taskType', description='This parameter is required.', example='text'),
  templateIds?: [ string ](name='templateIds'),
  transcription?: {
    asrModelCode?: string(name='asrModelCode'),
    autoSplit?: int32(name='autoSplit', example='1'),
    clientChannel?: int32(name='clientChannel', example='1'),
    fileName?: string(name='fileName', description='This parameter is required.', example='sss.mp3'),
    level?: string(name='level'),
    roleIdentification?: boolean(name='roleIdentification'),
    serviceChannel?: int32(name='serviceChannel', example='1'),
    serviceChannelKeywords?: [ string ](name='serviceChannelKeywords'),
    vocabularyId?: string(name='vocabularyId'),
    voiceFileUrl?: string(name='voiceFileUrl', description='This parameter is required.', example='http://1111.com/sss.mp3'),
  }(name='transcription'),
  variables?: [ 
    {
      variableCode?: string(name='variableCode'),
      variableValue?: string(name='variableValue'),
    }
  ](name='variables'),
}

model CreateTaskResponseBody = {
  data?: {
    taskId?: string(name='taskId', example='20240905-********-93E9-5D45-B4EF-045743A34071'),
  }(name='data'),
  requestId?: string(name='requestId', example='9F1DB065-AE0D-5EE3-B1AF-48632CB0831C'),
  success?: string(name='success', example='True'),
}

model CreateTaskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateTaskResponseBody(name='body'),
}

/**
 * @summary 创建语音文件调用llm任务
 *
 * @param request CreateTaskRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateTaskResponse
 */
async function createTaskWithOptions(workspaceId: string, appId: string, request: CreateTaskRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateTaskResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.categoryTags)) {
    body['categoryTags'] = request.categoryTags;
  }
  if (!Util.isUnset(request.customPrompt)) {
    body['customPrompt'] = request.customPrompt;
  }
  if (!Util.isUnset(request.dialogue)) {
    body['dialogue'] = request.dialogue;
  }
  if (!Util.isUnset(request.examples)) {
    body['examples'] = request.examples;
  }
  if (!Util.isUnset(request.fields)) {
    body['fields'] = request.fields;
  }
  if (!Util.isUnset(request.modelCode)) {
    body['modelCode'] = request.modelCode;
  }
  if (!Util.isUnset(request.responseFormatType)) {
    body['responseFormatType'] = request.responseFormatType;
  }
  if (!Util.isUnset(request.resultTypes)) {
    body['resultTypes'] = request.resultTypes;
  }
  if (!Util.isUnset(request.serviceInspection)) {
    body['serviceInspection'] = request.serviceInspection;
  }
  if (!Util.isUnset(request.taskType)) {
    body['taskType'] = request.taskType;
  }
  if (!Util.isUnset(request.templateIds)) {
    body['templateIds'] = request.templateIds;
  }
  if (!Util.isUnset(request.transcription)) {
    body['transcription'] = request.transcription;
  }
  if (!Util.isUnset(request.variables)) {
    body['variables'] = request.variables;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateTask',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/${OpenApiUtil.getEncodeParam(workspaceId)}/ccai/app/${OpenApiUtil.getEncodeParam(appId)}/createTask`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建语音文件调用llm任务
 *
 * @param request CreateTaskRequest
 * @return CreateTaskResponse
 */
async function createTask(workspaceId: string, appId: string, request: CreateTaskRequest): CreateTaskResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createTaskWithOptions(workspaceId, appId, request, headers, runtime);
}

model CreateVocabRequest {
  audioModelCode?: string(name='audioModelCode', example='nls'),
  description?: string(name='description'),
  name?: string(name='name', description='This parameter is required.'),
  wordWeightList?: [ 
    {
      weight?: int32(name='weight', description='This parameter is required.', example='2'),
      word?: string(name='word', description='This parameter is required.'),
    }
  ](name='wordWeightList', description='This parameter is required.'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='llm-9****me1'),
}

model CreateVocabResponseBody = {
  data?: {
    vocabularyId?: string(name='vocabularyId', example='f3d82*******7'),
  }(name='data'),
  requestId?: string(name='requestId', example='968A8634-FA2C-5381-9B3E-*******F'),
  success?: string(name='success', example='True'),
}

model CreateVocabResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CreateVocabResponseBody(name='body'),
}

/**
 * @summary 创建热词
 *
 * @param request CreateVocabRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return CreateVocabResponse
 */
async function createVocabWithOptions(request: CreateVocabRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateVocabResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.audioModelCode)) {
    body['audioModelCode'] = request.audioModelCode;
  }
  if (!Util.isUnset(request.description)) {
    body['description'] = request.description;
  }
  if (!Util.isUnset(request.name)) {
    body['name'] = request.name;
  }
  if (!Util.isUnset(request.wordWeightList)) {
    body['wordWeightList'] = request.wordWeightList;
  }
  if (!Util.isUnset(request.workspaceId)) {
    body['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateVocab',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/vocab/createVocab`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 创建热词
 *
 * @param request CreateVocabRequest
 * @return CreateVocabResponse
 */
async function createVocab(request: CreateVocabRequest): CreateVocabResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createVocabWithOptions(request, headers, runtime);
}

model DeleteVocabRequest {
  vocabularyId?: string(name='vocabularyId', description='This parameter is required.', example='ern*******rve'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='llm-0*****jlg8s'),
}

model DeleteVocabResponseBody = {
  data?: string(name='data', example='true'),
  requestId?: string(name='requestId', example='968A8634-FA2C-5381-9B3E-*******F'),
  success?: string(name='success', example='true'),
}

model DeleteVocabResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteVocabResponseBody(name='body'),
}

/**
 * @summary 删删除热词
 *
 * @param request DeleteVocabRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteVocabResponse
 */
async function deleteVocabWithOptions(request: DeleteVocabRequest, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteVocabResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.vocabularyId)) {
    body['vocabularyId'] = request.vocabularyId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    body['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteVocab',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/vocab/deleteVocab`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 删删除热词
 *
 * @param request DeleteVocabRequest
 * @return DeleteVocabResponse
 */
async function deleteVocab(request: DeleteVocabRequest): DeleteVocabResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteVocabWithOptions(request, headers, runtime);
}

model GetTaskResultRequest {
  requiredFieldList?: [ string ](name='requiredFieldList'),
  taskId?: string(name='taskId', example='20240905-********-93E9-5D45-B4EF-045743A34071'),
}

model GetTaskResultShrinkRequest {
  requiredFieldListShrink?: string(name='requiredFieldList'),
  taskId?: string(name='taskId', example='20240905-********-93E9-5D45-B4EF-045743A34071'),
}

model GetTaskResultResponseBody = {
  data?: {
    asrResult?: [ 
      {
        begin?: long(name='begin'),
        emotionValue?: int32(name='emotionValue'),
        end?: long(name='end'),
        role?: string(name='role'),
        speechRate?: int32(name='speechRate'),
        words?: string(name='words'),
      }
    ](name='asrResult'),
    extra?: string(name='extra'),
    taskErrorMessage?: string(name='taskErrorMessage'),
    taskId?: string(name='taskId', example='20240905-********-93E9-5D45-B4EF-045743A34071'),
    taskStatus?: string(name='taskStatus', example='FINISH'),
    text?: string(name='text'),
  }(name='data'),
  requestId?: string(name='requestId', example='968A8634-FA2C-5381-9B3E-C552DED7E8BF'),
  success?: string(name='success', example='True'),
}

model GetTaskResultResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetTaskResultResponseBody(name='body'),
}

/**
 * @summary 语音文件调用大模型获取结果
 *
 * @param tmpReq GetTaskResultRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetTaskResultResponse
 */
async function getTaskResultWithOptions(tmpReq: GetTaskResultRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetTaskResultResponse {
  Util.validateModel(tmpReq);
  var request = new GetTaskResultShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.requiredFieldList)) {
    request.requiredFieldListShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.requiredFieldList, 'requiredFieldList', 'simple');
  }
  var query : map[string]any = {};
  if (!Util.isUnset(request.requiredFieldListShrink)) {
    query['requiredFieldList'] = request.requiredFieldListShrink;
  }
  if (!Util.isUnset(request.taskId)) {
    query['taskId'] = request.taskId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetTaskResult',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/ccai/app/getTaskResult`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 语音文件调用大模型获取结果
 *
 * @param request GetTaskResultRequest
 * @return GetTaskResultResponse
 */
async function getTaskResult(request: GetTaskResultRequest): GetTaskResultResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getTaskResultWithOptions(request, headers, runtime);
}

model GetVocabRequest {
  vocabularyId?: string(name='vocabularyId', description='This parameter is required.', example='dhbf***rbrdb'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='llm-9864***1'),
}

model GetVocabResponseBody = {
  data?: {
    audioModelCode?: string(name='audioModelCode', example='nls'),
    description?: string(name='description'),
    name?: string(name='name'),
    vocabularyId?: string(name='vocabularyId', example='rrbe***jrvrdd'),
    wordWeightList?: [ 
      {
        weight?: int32(name='weight', example='1'),
        word?: string(name='word'),
      }
    ](name='wordWeightList'),
  }(name='data'),
  requestId?: string(name='requestId', example='968A8634-FA2C-5381-9B3E-*******F'),
  success?: string(name='success', example='true'),
}

model GetVocabResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: GetVocabResponseBody(name='body'),
}

/**
 * @summary 获取热词
 *
 * @param request GetVocabRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return GetVocabResponse
 */
async function getVocabWithOptions(request: GetVocabRequest, headers: map[string]string, runtime: Util.RuntimeOptions): GetVocabResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.vocabularyId)) {
    body['vocabularyId'] = request.vocabularyId;
  }
  if (!Util.isUnset(request.workspaceId)) {
    body['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'GetVocab',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/vocab/getVocab`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 获取热词
 *
 * @param request GetVocabRequest
 * @return GetVocabResponse
 */
async function getVocab(request: GetVocabRequest): GetVocabResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getVocabWithOptions(request, headers, runtime);
}

model ListVocabRequest {
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='llm-jhfr****8v'),
}

model ListVocabResponseBody = {
  data?: [ 
    {
      audioModelCode?: string(name='audioModelCode', example='nls'),
      description?: string(name='description'),
      name?: string(name='name'),
      vocabularyId?: string(name='vocabularyId', example='dv*****erverve'),
      wordWeightList?: [ 
        {
          weight?: int32(name='weight', example='3'),
          word?: string(name='word'),
        }
      ](name='wordWeightList'),
    }
  ](name='data'),
  requestId?: string(name='requestId', example='968A8634-FA2C-5381-9B3E-*******F'),
  success?: string(name='success', example='true'),
}

model ListVocabResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: ListVocabResponseBody(name='body'),
}

/**
 * @summary 热词列表
 *
 * @param request ListVocabRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return ListVocabResponse
 */
async function listVocabWithOptions(request: ListVocabRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListVocabResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.workspaceId)) {
    body['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListVocab',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/vocab/listVocab`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 热词列表
 *
 * @param request ListVocabRequest
 * @return ListVocabResponse
 */
async function listVocab(request: ListVocabRequest): ListVocabResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listVocabWithOptions(request, headers, runtime);
}

model RunCompletionRequest {
  dialogue?: {
    sentences?: [ 
      {
        chatId?: string(name='ChatId'),
        role?: string(name='Role', description='This parameter is required.', example='user'),
        text?: string(name='Text', description='This parameter is required.'),
      }
    ](name='Sentences'),
    sessionId?: string(name='SessionId', example='d25zc9c7004f8dad2b454d'),
  }(name='Dialogue', description='This parameter is required.'),
  fields?: [ 
    {
      code?: string(name='Code', example='phoneNumber'),
      desc?: string(name='Desc'),
      enumValues?: [ 
        {
          desc?: string(name='Desc'),
          enumValue?: string(name='EnumValue', description='This parameter is required.'),
        }
      ](name='EnumValues'),
      name?: string(name='Name', description='This parameter is required.'),
    }
  ](name='Fields'),
  modelCode?: string(name='ModelCode', example='ccai-14b'),
  serviceInspection?: {
    inspectionContents?: [ 
      {
        content?: string(name='Content'),
        title?: string(name='Title', description='This parameter is required.'),
      }
    ](name='InspectionContents'),
    inspectionIntroduction?: string(name='InspectionIntroduction'),
    sceneIntroduction?: string(name='SceneIntroduction'),
  }(name='ServiceInspection'),
  stream?: boolean(name='Stream', example='false'),
  templateIds?: [ long ](name='TemplateIds', description='This parameter is required.'),
  responseFormatType?: string(name='responseFormatType'),
  variables?: [ 
    {
      variableCode?: string(name='variableCode'),
      variableValue?: string(name='variableValue'),
    }
  ](name='variables'),
}

model RunCompletionResponseBody = {
  finishReason?: string(name='FinishReason'),
  requestId?: string(name='RequestId', example='17204B98-xxxx-4F9A-8464-2446A84821CA'),
  text?: string(name='Text'),
  inputTokens?: string(name='inputTokens'),
  outputTokens?: string(name='outputTokens'),
  totalTokens?: string(name='totalTokens'),
}

model RunCompletionResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RunCompletionResponseBody(name='body'),
}

/**
 * @summary CCAI服务面API
 *
 * @param request RunCompletionRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return RunCompletionResponse
 */
async function runCompletionWithOptions(workspaceId: string, appId: string, request: RunCompletionRequest, headers: map[string]string, runtime: Util.RuntimeOptions): RunCompletionResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dialogue)) {
    body['Dialogue'] = request.dialogue;
  }
  if (!Util.isUnset(request.fields)) {
    body['Fields'] = request.fields;
  }
  if (!Util.isUnset(request.modelCode)) {
    body['ModelCode'] = request.modelCode;
  }
  if (!Util.isUnset(request.serviceInspection)) {
    body['ServiceInspection'] = request.serviceInspection;
  }
  if (!Util.isUnset(request.stream)) {
    body['Stream'] = request.stream;
  }
  if (!Util.isUnset(request.templateIds)) {
    body['TemplateIds'] = request.templateIds;
  }
  if (!Util.isUnset(request.responseFormatType)) {
    body['responseFormatType'] = request.responseFormatType;
  }
  if (!Util.isUnset(request.variables)) {
    body['variables'] = request.variables;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RunCompletion',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/${OpenApiUtil.getEncodeParam(workspaceId)}/ccai/app/${OpenApiUtil.getEncodeParam(appId)}/completion`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary CCAI服务面API
 *
 * @param request RunCompletionRequest
 * @return RunCompletionResponse
 */
async function runCompletion(workspaceId: string, appId: string, request: RunCompletionRequest): RunCompletionResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return runCompletionWithOptions(workspaceId, appId, request, headers, runtime);
}

model RunCompletionMessageRequest {
  messages?: [ 
    {
      content?: string(name='Content', description='This parameter is required.'),
      role?: string(name='Role', description='This parameter is required.', example='user'),
    }
  ](name='Messages', description='This parameter is required.'),
  modelCode?: string(name='ModelCode', example='ccai-14b'),
  stream?: boolean(name='Stream', example='false'),
  responseFormatType?: string(name='responseFormatType'),
}

model RunCompletionMessageResponseBody = {
  finishReason?: string(name='FinishReason'),
  requestId?: string(name='RequestId', example='17204B98-xxxx-4F9A-8464-2446A84821CA'),
  text?: string(name='Text'),
  inputTokens?: string(name='inputTokens'),
  outputTokens?: string(name='outputTokens'),
  totalTokens?: string(name='totalTokens'),
}

model RunCompletionMessageResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: RunCompletionMessageResponseBody(name='body'),
}

/**
 * @summary CCAI服务面API
 *
 * @param request RunCompletionMessageRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return RunCompletionMessageResponse
 */
async function runCompletionMessageWithOptions(workspaceId: string, appId: string, request: RunCompletionMessageRequest, headers: map[string]string, runtime: Util.RuntimeOptions): RunCompletionMessageResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.messages)) {
    body['Messages'] = request.messages;
  }
  if (!Util.isUnset(request.modelCode)) {
    body['ModelCode'] = request.modelCode;
  }
  if (!Util.isUnset(request.stream)) {
    body['Stream'] = request.stream;
  }
  if (!Util.isUnset(request.responseFormatType)) {
    body['responseFormatType'] = request.responseFormatType;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'RunCompletionMessage',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/${OpenApiUtil.getEncodeParam(workspaceId)}/ccai/app/${OpenApiUtil.getEncodeParam(appId)}/completion_message`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary CCAI服务面API
 *
 * @param request RunCompletionMessageRequest
 * @return RunCompletionMessageResponse
 */
async function runCompletionMessage(workspaceId: string, appId: string, request: RunCompletionMessageRequest): RunCompletionMessageResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return runCompletionMessageWithOptions(workspaceId, appId, request, headers, runtime);
}

model UpdateVocabRequest {
  description?: string(name='description'),
  name?: string(name='name'),
  vocabularyId?: string(name='vocabularyId', description='This parameter is required.', example='dsvsv***dsvv'),
  wordWeightList?: [ 
    {
      weight?: int32(name='weight', description='This parameter is required.', example='2'),
      word?: string(name='word', description='This parameter is required.'),
    }
  ](name='wordWeightList'),
  workspaceId?: string(name='workspaceId', description='This parameter is required.', example='llm-jhfr****w8v'),
}

model UpdateVocabResponseBody = {
  data?: string(name='data', example='true'),
  requestId?: string(name='requestId', example='968A8634-FA2C-5381-9B3E-*******F'),
  success?: string(name='success', example='true'),
}

model UpdateVocabResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: UpdateVocabResponseBody(name='body'),
}

/**
 * @summary 修改热词
 *
 * @param request UpdateVocabRequest
 * @param headers map
 * @param runtime runtime options for this request RuntimeOptions
 * @return UpdateVocabResponse
 */
async function updateVocabWithOptions(request: UpdateVocabRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateVocabResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.description)) {
    body['description'] = request.description;
  }
  if (!Util.isUnset(request.name)) {
    body['name'] = request.name;
  }
  if (!Util.isUnset(request.vocabularyId)) {
    body['vocabularyId'] = request.vocabularyId;
  }
  if (!Util.isUnset(request.wordWeightList)) {
    body['wordWeightList'] = request.wordWeightList;
  }
  if (!Util.isUnset(request.workspaceId)) {
    body['workspaceId'] = request.workspaceId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateVocab',
    version = '2024-06-03',
    protocol = 'HTTPS',
    pathname = `/vocab/updateVocab`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 修改热词
 *
 * @param request UpdateVocabRequest
 * @return UpdateVocabResponse
 */
async function updateVocab(request: UpdateVocabRequest): UpdateVocabResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateVocabWithOptions(request, headers, runtime);
}

